<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/html/axios.min.js"></script>
    <script src="/html/util.js"></script>
    <script>
        window.onload = function (){
            getUserName();
            showProductList();
        }
        function getUserName(){
            axios.get("/user/getUserName",null).then(e=>{
                $("userSpan").innerText = e.data;
            });

        }
        function showProductList(){
            axios.get("/product/findAll",null).then(e=>{

                var info = e.data;
                var str ="";
                for(var i=0;i<info.length;i++){
                    str +=`<div><img src="/html/image/${info[i].img}"
                    width="200" height="200"><br>${info[i].name}<br>
                    <a href="/html/speak.html?id=${info[i].id}">查看</a></div>`
                }
                $("productDiv").innerHTML = str;
            });

        }


    </script>
</head>
<body>
    欢迎光临:<span id="userSpan"></span>

<div style="display: flex" id="productDiv">
</div>
</body>
</html>